package lucene.server.cdc.mysql;

import com.github.shyiko.mysql.binlog.BinaryLogClient;

import java.util.Properties;
import java.util.logging.Logger;

public class ClientLifeCycleListener implements BinaryLogClient.LifecycleListener {

    Logger logger = Logger.getLogger(ClientLifeCycleListener.class.getName());
    Properties properties;

    public ClientLifeCycleListener(Properties properties) {
        this.properties  = properties;
    }

    @Override
    public void onConnect(BinaryLogClient client) {

    }

    @Override
    public void onCommunicationFailure(BinaryLogClient client, Exception ex) {
        System.out.println(properties.getProperty("name")+ "错误," + ex.getMessage() + "." + client.getBinlogFilename() + "/" + client.getBinlogPosition());
    }

    @Override
    public void onEventDeserializationFailure(BinaryLogClient client, Exception ex) {
        System.out.println(properties.getProperty("name")+ "错误," + ex.getMessage());
    }

    @Override
    public void onDisconnect(BinaryLogClient client) {
        System.out.println(properties.getProperty("name")+ "断开连接");

    }
}
